const API_URL = 'http://localhost:3000'
const DB_CONFIG = {
    host: 'localhost', //主机名 localhost / 127.0.0.1
    user: 'root', //数据库用户名 root
    password: 'root', //密码 root
    port: 3306, //端口号 3306 默认可以省略
    database: 'u_course', //要操作的数据库
}
let suozi = '春风不解风情'
const jwt = require('jsonwebtoken')

function getToken(data, expiresIn) {
    let exp = expiresIn || 24 * 60 * 60;
    return jwt.sign(data, suozi, {
        expiresIn: exp
    })
}

function verifyToken(token) {
    try {
        return jwt.verify(token, suozi)
    } catch (error) {
        return false
    }
}

module.exports = {
    API_URL,
    DB_CONFIG,
    suozi,
    getToken,
    verifyToken
}